import 'dart:convert';

class BannerListModel {
  List<BannerModel>? list;

  BannerListModel({this.list});

  factory BannerListModel.fromRawJson(String str) =>
      BannerListModel.fromJson(json.decode(str));

  String toRawJson() => json.encode(toJson());

  factory BannerListModel.fromJson(Map<String, dynamic> json) =>
      BannerListModel(
        list: List<BannerModel>.from(
          json["list"].map((x) => BannerModel.fromJson(x)),
        ),
      );

  Map<String, dynamic> toJson() => {
    "list": List<dynamic>.from(list!.map((x) => x.toJson())),
  };
}

class BannerModel {
  ///轮播图ID
  int? id;

  ///图片
  String? imgUrl;

  ///类型：1-短剧 2-内链 3-外链
  int? type;

  ///对应type的内容,
  ///type = 1； content=剧集ID，
  ///type = 2； content=APP内部跳转路径，
  ///type = 3； content=浏览器打开链接，
  String? content;

  ///最后一次观看的剧集ID
  int? lastWatchEpisodesId;

  BannerModel({
    this.id,
    this.imgUrl,
    this.type,
    this.content,
    this.lastWatchEpisodesId,
  });

  factory BannerModel.fromRawJson(String str) =>
      BannerModel.fromJson(json.decode(str));

  String toRawJson() => json.encode(toJson());

  factory BannerModel.fromJson(Map<String, dynamic> json) => BannerModel(
    id: json["id"],
    imgUrl: json["img_url"],
    type: json["type"],
    content: json["content"],
    lastWatchEpisodesId: json["last_watch_episodes_id"],
  );

  Map<String, dynamic> toJson() => {
    "id": id,
    "img_url": imgUrl,
    "type": type,
    "content": content,
    "last_watch_episodes_id": lastWatchEpisodesId,
  };
}
